﻿
namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using FluentValidation;
    using Huirui.Cavan.Domain.MainBoundedContext.Resources;

    public class UserAccountValidator : AbstractValidator<UserAccount>
    {
        public UserAccountValidator()
        {
            RuleFor(ua => ua.Name).NotEmpty().WithMessage(Messages.Validate_UserAccountNameIsInvalid).Length(2, 20).WithMessage(Messages.Validate_UserAccountNameIsInvalid);
            RuleFor(ua => ua.Password).NotEmpty().WithMessage(Messages.Validate_UserAccountPasswordIsInvalid).Matches(@"^[a-z1-9]{6,20}$").WithMessage(Messages.Validate_UserAccountPasswordIsInvalid);
            RuleFor(ua => ua.Email).EmailAddress().WithMessage(Messages.Validate_EmailIsInvalid);
        }
    }
}
